import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';

import '../common/MMKVTags.dart';
import '../main.dart';
import 'app_home_page.dart';
import 'login_page.dart';

class InitPage extends StatefulWidget{
  const InitPage({super.key});

  @override
  State<StatefulWidget> createState() => _StateInitPage();
}

class _StateInitPage extends State<InitPage> with WidgetsBindingObserver{

  bool _isInitIMSDK = true;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    WidgetsBinding.instance.addObserver(this);
    FlutterNativeSplash.remove();
  }

  @override
  Widget build(BuildContext context) {
    bool condition = prefs.getBool(MMKVTags.LOGIN_TAG) ?? false;//还没有登录
    print('condition:$condition');
    if(!condition){
      return const LoginPage();
      // return const VerifyCodePage();
    }else{
      if (_isInitIMSDK) {
        return const AppHomePage();
      } else {
        return Container();
      }
    }
  }
}
